package com.ruoyi.web.controller.app;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.project.domain.ProProject;
import com.ruoyi.project.service.IProProjectService;
import com.ruoyi.system.domain.SysUser;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@Api("项目管理")
@Controller
@RequestMapping("/api/project")
public class ProjectController extends BaseController{

	@Autowired
	private IProProjectService proProjectService;

	@ApiOperation("项目经理-手工维护需派单合同款项")
	@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
	@GetMapping("/getMyDispatchProjectList")
	@ResponseBody
	public AjaxResult getMyDispatchProjectList(Long userId){
		// 获取当前的用户名称
		if(userId == null){
			SysUser currentUser = ShiroUtils.getSysUser();
			userId = currentUser.getUserId();
		}
		ProProject project = new ProProject();
		project.setPmId(userId);
		List<Map<String, Object>> projectList = proProjectService.getMyDispatchProjectList(project);
		return AjaxResult.success(projectList);
	}

}
